<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卡片出入库统计</title>

<script type="text/javascript" src="../script/common.js"></script>
<script language="javascript" src="../script/common_stat.js"></script>
<script type="text/javascript" src="../script/pivot.js"></script>
<script type="text/javascript" src="../script/print.js"></script>
<script type="text/javascript" src="../script/crosstab.js"></script>

<script type="text/javascript">
	var crosstab = new Crosstab();
	
	var statForm;
	var pivot;
	function load(){
		Eui.showNavigation();
		setPages(["queryView","newPivot"]);
	
		
		statForm = $("statForm");
		Common.initDict(statForm.cardStatus, "card_status", "全 部");
		
		statForm.orgId.value = Common.cOrg().id;
		$("orgName").value = Common.cOrg().name;
		CardStore.initCardStoreStat("stat_btn")
		 newPivot()
	}
	
	function selCardType(){
		var v = openDialogFrame("/basic/card_type_list.html?",'请选择卡片类型',464,700);
		if(v){
			statForm.cardType.value=v[1];
			statForm.cardTypeId.value=v[0];
		}
	}
	function newPivot(){
		var sql = "card_stock_stat";
		var crossconf = {};
		crossconf.measures = {"startAmount":"期初库存","endAmount":"期末库存","deliveryCount":"出库次数","deliveryAmount":"出库数量","warehousingCount":"入库次数","warehousingAmount":"入库数量","adjustCount":"调整次数","adjustAmount":"调整数量"}
		crossconf.dimensions = {"cardType":{name:"卡片类型",option:{"baseCardType":"基本卡片类型","name":"名称"}},"cardStatus":""}
		crossconf.defaultMeasure = {startAmount:true,warehousingCount:true,warehousingAmount:true,deliveryCount:true,deliveryAmount:true,adjustCount:true,adjustAmount:true,endAmount:true};
		crossconf.defaultVertical = {};
		crossconf.defaultHorizon = {cardStatus:true,cardType:{baseCardType:true,name:true}};
		pivot = new Pivot('newPivot',sql,null,{disableConf:true,initPivotHead:initPivotHead});
		//pivot.ShowZero = true;
		pivot.initConf(crossconf);
		pivot.setPivotHead('pivotTitle','出入库统计');
	}
	function initPivotHead(div){
		var title = '<table width="100%" border="0" cellspacing="0" cellpadding="5" style="width:600">'
				  + '<tr><td align="center" class="reportTitle" height="50" colspan="3" id="#DIVID#_pivotTitle"></td></tr>'
				  + '<tr><td width="32%">统 计 人：<span id="#DIVID#_statOper"></span></td><td width="35%">统计机构：<span id="#DIVID#_statOrg"></span></td><td>统计时间：<span id="#DIVID#_statTime"></span></td></tr>'
				  + '<tr><td>机构名称：<span id="#DIVID#_orgName"></span></td><td>卡片类型：<span id="#DIVID#_cardType"></span></td><td>卡片状态：<span id="#DIVID#_cardStatus"></span></td></tr>'
				  + '<tr><td>起始时间：<span id="#DIVID#_beginDate"></span></td><td>结束时间：<span id="#DIVID#_endDate"></span></td></tr></table>';
		$(div+'_pivot_head').innerHTML = title.replace(/#DIVID#/g,div);
	}
	function doQuery(){
		CardStore.formatStatDate()
		if(!checkForm(statForm)) return;
		pivot.param = Common.getValues(statForm);
		pivot.setPivotHead('statTime',Format.today(true));
		pivot.setPivotHead('statOper',Common.cOperator().name);
		pivot.setPivotHead('statOrg',Common.cOrg().name);
		pivot.setPivotHead('orgName',pivot.param.orgName);
		pivot.setPivotHead('cardType',pivot.param.cardType?pivot.param.cardType:"全部");
		pivot.setPivotHead('cardStatus',pivot.param.cardStatus?Common.getText("card_status",pivot.param.cardStatus):"全部");
		pivot.setPivotHead('beginDate',pivot.param.beginDate);
		pivot.setPivotHead('endDate',pivot.param.endDate);
		
		switchPage('newPivot');
		pivot.refresh();
	}
	
	function resetStatForm(){
		
		statForm.orgId.value = Common.cOrg().id;
		$("orgName").value = Common.cOrg().name;
		switchPage('queryView');
	}
	//选择机构方法
	function setOrg(sorg) {
		$("orgName").value = sorg.name;
	    $("orgId").value = sorg.id;
	}
	
</script>
</head>

<body onload="load()">
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="queryView" class="form">
		<div class="formTitle">卡片出入库统计：查询条件</div>
		<form id="statForm" name="statForm">
			<input type="hidden" name="orgId"/>
			<input type="hidden" name="cardTypeId"/>
			<table cellSpacing=0 cellPadding=4 width="100%" border=0 class="label4">
				<tr>
				 	<td><label>卡片状态</label> <select name="cardStatus" ><option></option></select></td>
				</tr>
				<tr>
				 	<td><label>卡片类型</label> <input type="text" name="cardType"> <a class=orga title="选择类型" href="javascript:void(0)" onclick="selCardType()">&nbsp;&nbsp;</a></td>
				</tr>
				<tr>
					<td><label>机构名称</label> <input type="text" name="orgName" class="readonly"> <a class="orga" href="#" onclick="SystemMgnt.selOrg(setOrg);">&nbsp;&nbsp;</a></td>
				</tr>
			</table>
			<div id="stat_btn"></div>
		</form>
	</div>
	<!-- Flash 报表-->
	<div id="newPivot" style="display:none;"></div>
</body>

</html>
